<%--
  Created by IntelliJ IDEA.
  User: Gaara_XHG
  Date: 2020/10/13
  Time: 14:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>车辆封面上传</title>
    <link rel="stylesheet" type="text/css" href="/prj/plugins/layui/css/layui.css">
</head>
<body>
<%--        ngix实现图片上传begin--%>
<div>
    <div class="layui-upload-drag" id="test10">
        <i class="layui-icon">车辆封面</i>
        <p>点击上传，或将文件拖拽到此处</p>
        <div class="layui-hide" id="uploadDemoView">
            <hr>
            <img src="" alt="上传成功后渲染" style="max-width: 196px">
        </div>
    </div>
</div>
<%--        ngix实现图片上传end--%>
<%--去上传车辆展示图片（最多四张）--%>
<div>
    <a href="${pageContext.request.contextPath}/AdminJsp/toNewCarDesc/${carID}">去上传车辆展示图片</a>
</div>
<%--返回管理员页面--%>
<div>
    <a href="${pageContext.request.contextPath}/AdminJsp/toAdmin">返回管理员页面</a>
</div>
<script src="${pageContext.request.contextPath}/plugins/jquery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/layui/layui.js"></script>

<script>
    layui.use('upload',function(){
        let upload = layui.upload;//初始化
        let element = layui.element;//初始化进度条
        //拖拽上传
        upload.render({
            elem: '#test10'
            ,url: '/prj/uploadCar/carMain/nginx/${carID}' //改成您自己的上传接口
            ,done: function(res){
                console.log(res)
                layer.msg('上传成功',{icon:6});
                // layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', "/prj/images/carMain"+res.data);
                layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', "http://localhost/carJY/carMain/"+res.data);
                console.log(res);
            }
        });
    })
</script>

</body>
</html>
